
cc.Class({
    extends: cc.Component,

    properties: {
        ed_username:cc.EditBox,
    },

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {},

    start () {

    },

    init(itemData){
        this.itemData = itemData;
    },


    btn_confirmClicked(){
        // 判断用户名输入是否正确

        let cur_username = this.ed_username.string.trim();
        if(cur_username !== this.itemData.uname){
            G.showToast('要删除的用户名错误!');
            this.ed_username.string = '';
            return;
        }else{
            // 请求删除
            G.netApi.item_delete({kid:this.itemData._kid},(err,data)=>{
                if(err){
                    G.showToast('删除错误! err:' + err);
                }else{
                    if(data.err){
                       G.showToast('删除失败!');
                    }else{
                        G.showToast('删除成功!');

                        G.deleteItemByKid(this.itemData._kid);

                        // 显示allItem界面
                        G.gameCtrl.naviToAllItem(G.allData);
                    }
                }
            });
        }
    },
    btn_cancelClicked(){
        this.node.destroy();
    },
});
